package com.netease.nie.service;

import java.util.Collections;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.netease.nie.dao.CountryDao;
import com.netease.nie.model.Country;

@Service
public class CountryService {
	
	@Autowired
	private CountryDao countryDao;
	
	
//	public List<City> getList(){
//        String sql = "SELECT id,name,state  FROM city";
//        return (List<City>) jdbcTemplate.query(sql, new RowMapper<City>(){
//
//            public City mapRow(ResultSet rs, int rowNum) throws SQLException {
//            	City stu = new City();
//                stu.setId(rs.getLong("id"));
//                stu.setState(rs.getString("state"));
//                stu.setName(rs.getString("name"));
//                return stu;
//            }
//
//        });
//    }
	
	public List<Country> listAllCountry(){
        System.out.println("222222222");
        List<Country> list = Collections.EMPTY_LIST;
		try {
			list = countryDao.listAllCountry();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return list;
    }
	
	public int addCountry() {
		Country country = new Country();
		country.setId(200L);
		country.setCountrycode("11112");
		country.setCountryname("old");
//		country.setCountrycode("AF");
//		country.setCountryname("Afghanistan");
//		country.setCountrycode("AO");
//		country.setCountryname("Angola");
		int i = countryDao.addCountry(country);
		return country.getId().intValue();
	}
	
	public Country queryCountryById() {
		return countryDao.queryCountryById();
	}
	
}
